package com.tql.mall.rabbit.model;

import com.tql.mall.rabbit.constant.MqConstant;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.amqp.rabbit.connection.CorrelationData;

/**
 * @Author: tyk
 * @Date: 2023/5/18 20:34
 * @Description: 消息
 */
@Data
@NoArgsConstructor
public class MallCorrelationData extends CorrelationData {
    //  消息
    private Object msg;
    //  交换机
    private String exchange;
    //  路由
    private String routingKey;
    //  可重试次数
    private int retryCount;
    //  是否为延迟消息
    private boolean isDelay;
    //  延迟时间
    private int delayTime;

    public MallCorrelationData(String id, Object msg, String exchange, String routingKey) {
        this(
                id,
                msg,
                exchange,
                routingKey,
                MqConstant.DEFAULT_RETRY_COUNT,
                MqConstant.DEFAULT_IS_DELAY,
                MqConstant.DEFAULT_DELAY_TIME
        );
    }

    public MallCorrelationData(
            String id, Object msg, String exchange, String routingKey, int retryCount, boolean isDelay, int delayTime
    ) {
        super(id);
        this.msg = msg;
        this.exchange = exchange;
        this.routingKey = routingKey;
        this.retryCount = retryCount;
        this.isDelay = isDelay;
        this.delayTime = delayTime;
    }
}
